﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Event.ReactiveProgramming
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var query = Enumerable.Range(1, 10).Select(x =>
            {
                Thread.Sleep(100);
                return x.ToString();
            });

            var sequence = Enumerable.Range(1, 10);
            var observableSequence = query.ToObservable();
            var observer = Observer.Create<int>(i => this.richTextBox1.AppendText(string.Format("{0} in thread {1}", i, Thread.CurrentThread.ManagedThreadId)), () => richTextBox1.AppendText("finished"));
            //observableSequence.Subscribe(observer);
        }
    }
}
